class FightPawn extends UDKPawn
	placeable config(Game);

var() array< class<Inventory> > InventoryList;

var Rotator myRot;
var Vector myPos;
var AnimNodeSlot FullBodyAnimSlot;
var SkeletalMeshComponent Aikoo;
var float hitStart;
var float hitTime;

simulated function PostBeginPlay()
{
	super.PostBeginPlay();	
	FullBodyAnimSlot = AnimNodeSlot(Mesh.FindAnimNode('MyBodySlot'));
	SetInventory();
	//myRot = Rotation;
	//myPos = Location;
	//myPos.Z = 150;
}

DefaultProperties
{
	hitTime = 0.6; // hersteltijd na geslagen te zijn
	
	ControllerClass= class 'FightController'
	InventoryManagerClass=class'FigthInventoryManager'

	Begin Object Class=SkeletalMeshComponent Name=aikoo
		SkeletalMesh=SkeletalMesh'AikoVechtGame.Aiko' //de skeletal mesh
		PhysicsAsset=PhysicsAsset'AikoVechtGame.Aiko_Physics'
		AnimSets(0)=AnimSet'AikoVechtGame.Pelvis'
		AnimTreeTemplate=AnimTree'AikoVechtGame.Aiko_vecht_anim'
		Translation=(Z=-100)
	End Object

	Mesh=aikoo
	Components.Add(aikoo)
	Aikoo = aikoo;

	Begin Object Name=CollisionCylinder
		CollisionRadius=60
		CollisionHeight=100
	End Object

	Physics=Physics_Falling;
}

event Tick(float deltatime){

	//SetRotation(myRot);
	//SetLocation(myPos);
}

simulated function StartFire(byte FireModeNum)
{
	if( bNoWeaponFIring || WorldInfo.TimeSeconds <= hitStart+hitTime )
	{
		return;
	}
	
	if(FireModeNum == 1)
	{
		FightPlayerController(Controller).Block();
	}
	else if( Weapon != None )
	{
		FightPlayerController(Controller).blocking = false;
		Weapon.StartFire(0);
	}
}

event TakeDamage(int DamageAmount, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
{
	if(!Controller.IsInState('Block')  && !FightPlayerController(Controller).blocking)
	{
		super.TakeDamage(DamageAmount,none,HitLocation,Momentum,DamageType,HitInfo,DamageCauser);
		if(Controller != none)
			FightController(Controller).setDowntime(hitTime);
		PlayHitAnimation();
		hitStart = WorldInfo.TimeSeconds;
	}
	`log(Health);
}

function SetInventory()
{
	local int i;
	for ( i=0; i<InventoryList.Length; i++ )
	{
		CreateInventory( InventoryList[i], false  );
	}
}

simulated function WeaponFired(Weapon InWeapon, bool bViaReplication, optional vector HitLocation)
{
	PlaySlashAnimation();
}
 
simulated function bool CalcCamera(float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV)
{
	return false;
}

function AddDefaultInventory()
{
    //override do nothing
}

function PlayBlockAnimation()
{
	FullBodyAnimSlot.PlayCustomAnim('bLock',1,0.1,0.1,false,true);
}

function PlaySlashAnimation()
{
	`log('slash');
	FullBodyAnimSlot.PlayCustomAnim('Strike',1,0.1,0.1,false,true);
}

function PlayHitAnimation()
{
	`log('hit');
	FullBodyAnimSlot.PlayCustomAnim('Hit',1,0.1,0.1,false,true);
}
